package org.uk.splitsbrowser.shared;


import java.util.Date;

import javax.persistence.Id;
import javax.persistence.Version;


import com.google.gwt.user.client.rpc.IsSerializable;
import com.orientechnologies.orient.core.id.ORID;

public class OEvent implements IsSerializable {
	
	/** Data access object representing an orienteering event */
	public enum EventGrade {
	    WOC, NationalChampionships, International, National, Regional, Local 
	}
	
	public enum EventType {
	    Long, Middle, Sprint, UltaDistance, Relay, Other 
	}
	
	public enum EventDiscipline  {
	    Foot, Ski, Bike, Other 
	}
	
	@Id String id;
	
	@Version long version; 
	
	private String name;
	private String club;
	private String nationality;  // iso string
	private Date date;
	private Double Latitude;
	private Double Longitude;   
	private String webPage;
	private String contactEmail;
	private String comments; 
	private EventGrade grade; 
	private EventType type;
	private EventDiscipline discipline;
	private boolean hasMap;
	private boolean hasSplits;
	
	
	public OEvent() {
	}
	
	// Blank getters/setters.
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public long getVersion() {
		return version;
	}

	public void setVersion(long version) {
		this.version = version;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getClub() {
		return club;
	}
	public void setClub(String club) {
		this.club = club;
	}
	public String getNationality() {
		return nationality;
	}
	public void setNationality(String nationality) {
		this.nationality = nationality;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Double getLatitude() {
		return Latitude;
	}
	public void setLatitude(Double latitude) {
		Latitude = latitude;
	}
	public Double getLongitude() {
		return Longitude;
	}
	public void setLongitude(Double longitude) {
		Longitude = longitude;
	}
	public String getWebPage() {
		return webPage;
	}
	public void setWebPage(String webPage) {
		this.webPage = webPage;
	}
	public String getContactEmail() {
		return contactEmail;
	}
	public void setContactEmail(String contactEmail) {
		this.contactEmail = contactEmail;
	}
	public String getComments() {
		return comments;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public EventGrade getGrade() {
		return grade;
	}
	public void setGrade(EventGrade grade) {
		this.grade = grade;
	}
	public EventType getType() {
		return type;
	}
	public void setType(EventType type) {
		this.type = type;
	}
	public EventDiscipline getDiscipline() {
		return discipline;
	}
	public void setDiscipline(EventDiscipline discipline) {
		this.discipline = discipline;
	}
	public boolean isHasMap() {
		return hasMap;
	}
	public void setHasMap(boolean hasMap) {
		this.hasMap = hasMap;
	}
	public boolean isHasSplits() {
		return hasSplits;
	}
	public void setHasSplits(boolean hasSplits) {
		this.hasSplits = hasSplits;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((Latitude == null) ? 0 : Latitude.hashCode());
		result = prime * result
				+ ((Longitude == null) ? 0 : Longitude.hashCode());
		result = prime * result + ((club == null) ? 0 : club.hashCode());
		result = prime * result
				+ ((comments == null) ? 0 : comments.hashCode());
		result = prime * result
				+ ((contactEmail == null) ? 0 : contactEmail.hashCode());
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		result = prime * result
				+ ((discipline == null) ? 0 : discipline.hashCode());
		result = prime * result + ((grade == null) ? 0 : grade.hashCode());
		result = prime * result + (hasMap ? 1231 : 1237);
		result = prime * result + (hasSplits ? 1231 : 1237);
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((nationality == null) ? 0 : nationality.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		result = prime * result + (int) (version ^ (version >>> 32));
		result = prime * result + ((webPage == null) ? 0 : webPage.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OEvent other = (OEvent) obj;
		if (Latitude == null) {
			if (other.Latitude != null)
				return false;
		} else if (!Latitude.equals(other.Latitude))
			return false;
		if (Longitude == null) {
			if (other.Longitude != null)
				return false;
		} else if (!Longitude.equals(other.Longitude))
			return false;
		if (club == null) {
			if (other.club != null)
				return false;
		} else if (!club.equals(other.club))
			return false;
		if (comments == null) {
			if (other.comments != null)
				return false;
		} else if (!comments.equals(other.comments))
			return false;
		if (contactEmail == null) {
			if (other.contactEmail != null)
				return false;
		} else if (!contactEmail.equals(other.contactEmail))
			return false;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		if (discipline != other.discipline)
			return false;
		if (grade != other.grade)
			return false;
		if (hasMap != other.hasMap)
			return false;
		if (hasSplits != other.hasSplits)
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (nationality == null) {
			if (other.nationality != null)
				return false;
		} else if (!nationality.equals(other.nationality))
			return false;
		if (type != other.type)
			return false;
		if (version != other.version)
			return false;
		if (webPage == null) {
			if (other.webPage != null)
				return false;
		} else if (!webPage.equals(other.webPage))
			return false;
		return true;
	}

	
}
	
